﻿#pragma once

#include "Object.h"
#include "DataObject.h"
#include "Logging.h"

class Application;
class Mesh;
class System : public Object
{
public:
  System(const Configuration& cfg);
  virtual ~System(){};

  virtual void Init(){};
  virtual void InitVariable() {}
  virtual void Evolve() = 0;

  template<typename T>
  void AddCellVariable(const std::string& name)
  {
    _data_set.AddCellField(name, ArrayHandle<T>{});
  }

  template<typename T>
  void AddPointVariable(const std::string& name)
  {
    _data_set.AddPointField(name, ArrayHandle<T>{});
  }

  template<typename T>
  ArrayHandle<T> GetVariableArray(const std::string& name)
  {
    try
    {
      return _data_set.GetField(name).GetData().AsArrayHandle<ArrayHandle<T>>();
    }
    catch (const std::exception& e)
    {
      Error(e.what());
    }
  }

  const vtkm::cont::DataSet& GetDateSet() const;

protected:
  DataSet _data_set;
  Application& _app;
  Mesh& _mesh;

};
